package com.example.kotlindemo.函数

class 内部类 {
    private var name:String = "luge"
    inner class InnerClass{
        private var name2:String = "luge"
        fun inner() = this@内部类.name //inner class
        fun inner2() = this@InnerClass.name2 //inner class
    }


    //局部嵌套类
    fun getName():String{
         class InnerClass{
            private var name2:String = "luge"
            fun inner() = this@内部类.name //inner class
            fun inner2() = this@InnerClass.name2 //inner class
        }
        return InnerClass().inner()
    }

}


fun String.filter(predicate:(Char,Int)->Boolean):String{
    val i = 0
    var result = ""
    for (c in this.toCharArray()){
        if(predicate(c,i)){
            result += c
        }
    }
    return result
}

fun main() {
    var string = "1324qsdsdf1111"
    string = string.filter{
            ch, _ -> ch.isDigit()
        return@filter ch.isDigit()
    }
    println(string)
}